﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Last03.Common
{
    class DataOperation
    {
        public static readonly string[] AccountType = { "活期存款", "定期存款", "零存整取" };
        /// <summary>
        /// 获取操作员姓名
        /// </summary>
        /// <param name="id">操作员编号</param>
        /// <returns></returns>
        public static string GetOperateName(string id)
        {
            using (HotelEntities c = new HotelEntities())
            {
                //var q = from t in c.EmployeeInfo
                var q = from t in c.Ruzhu
                        where t.入住房间号 == id
                        
                        select t;
                if (q != null && q.Count() >= 1)
                {
                    return q.First().入住房间号;
                }
                else
                {
                    return "";
                }
            }
        }

        /// <summary>
        /// 根据存款类型创建存款用户
        /// </summary>
        /// <param name="accountType">存款类型</param>
        /// <returns></returns>
        //public static Custom CreateCustom(string accountType)
        //{
        //    Custom custom = null;
        //    switch (accountType)
        //    {
        //        case "活期存款":
        //            custom = new CustomChecking();
        //            break;
        //        case "定期存款":
        //            custom = new CustomFixed();
        //            break;
        //        case "零存整取":
        //            break;
        //    }
        //    custom.AccountInfo.accountType = accountType;
        //    return custom;
        //}

        /// <summary>
        /// 获取存款用户信息,并初始化余额
        /// </summary>
        /// <param name="accountNumber"></param>
        /// <returns></returns>
        //public static Custom GetCustom(string accountNumber)
        //{
        //    Custom custom = null;
        //    BankEntities c = new BankEntities();
        //    try
        //    {
        //        var q = (from t in c.AccountInfo
        //                 where t.accountNo == accountNumber
        //                 select t).Single();
        //        custom = CreateCustom(q.accountType);
        //        custom.AccountInfo.accountNo = accountNumber;
        //        custom.AccountInfo.accountName = q.accountName;
        //        custom.AccountInfo.accountPass = q.accountPass;
        //        custom.AccountInfo.IdCard = q.IdCard;
        //    }
        //    catch
        //    {
        //        return null;
        //    }
        //    var q1 = from t in c.MoneyInfo
        //             where t.accountNo == accountNumber
        //             select t;
        //    custom.AccountBalance = q1.Sum(x => x.dealMoney);
        //    return custom;
        //}

        /// <summary>
        /// 获取指定类别的利率
        /// </summary>
        /// <param name="rateType">利率类别</param>
        /// <returns>对应类别的利率值</returns>
        //public static double GetRate(RateType rateType)
        //{
        //    string type = rateType.ToString();
        //    HotelEntities c = new HotelEntities();
        //    var q = (from t in c.Ruzhu
        //             where t.入住房间号 == type
        //             select t.入住房间号).Single();
        //    return q.Value;
        //}
    }
}

